package routes

import (
	"gitee.com/zhengjianfeng/pay/services"
	"gitee.com/zhengjianfeng/pay/web/controllers"
	"gitee.com/zhengjianfeng/pay/web/middleware/jwts"
	"github.com/kataras/iris/v12"
	"github.com/kataras/iris/v12/mvc"
)

// Configure registers the necessary routes to the app.
func Configure(b *iris.Application) {
	var (
		api   *mvc.Application // 无需登录登录
		login *mvc.Application // 无需登录登录
		admin *mvc.Application // 需要登录凭证
	)

	api = mvc.New(b.Party("/"))
	api.Register(services.NewTestService())
	api.Handle(new(controllers.ApiController))

	login = mvc.New(b.Party("/login/"))
	login.Register(services.NewPayAccountService())
	login.Handle(new(controllers.AdminLoginController))

	admin = mvc.New(b.Party("/admin/", jwts.JwtHandler.Serve, jwts.GetBaseLoginInfo))
	admin.Register(services.NewPayAccountService())
	admin.Register(services.NewPayAgentService())
	admin.Handle(new(controllers.AdminIndexController))
	admin.Handle(new(controllers.AdminAgentController))
	admin.Handle(new(controllers.AdminGo))
}
